#ifndef QTMQTT_H
#define QTMQTT_H

#include <QWidget>
#include <QtMqtt/qmqttclient.h>
#include <QDateTime>
#include <QMessageBox>
#include <QPushButton>
#include <QString>
#include <QtMqtt/qmqttconnection_p.h>
#include <QMessageAuthenticationCode>
#include <QDebug>
#include <QtMqtt/qmqtttopicname.h>
#include <QtMqtt/qmqttsubscription.h>
#include <QHostInfo>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonParseError>

namespace Ui {
class qtMqtt;
}

class qtMqtt : public QWidget
{
    Q_OBJECT

public:
    explicit qtMqtt(QWidget *parent = nullptr);
    ~qtMqtt();

    void data_set();
    void data_show();

    //三元组
    QString ProductKey = "自己的ProductKey";
    QString DeviceName = "自己的DeviceName";
    QString DeviceSecret = "自己的DeviceSecret";

    QString RegionId="cn-shanghai";
    QString PubTopic;//发布topic
    QString SubTopic;//订阅topic
    QString targetServer;//域名
    QString clientId="ts1234";//这里随便写，最好是设备的Mac地址
    QString signmethod = "hmacsha1";
    QString timestamp ="789";//这里随便写，表示当前时间毫秒值
    QString message;
    QString allcode;

    QString Json_1;
    QString Json_2;

    int JsonNum_1 = 0;
    int JsonNum_2 = 0;

private slots:
    void on_connect_btn_clicked();

    void on_send_btn_clicked();

    void on_get_btn_clicked();

    void topicMessageReceived(const QByteArray &message, const QMqttTopicName &topic);

    void on_new_btn_clicked();

    void on_clearButton_clicked();

private:
    Ui::qtMqtt *ui;

    QMqttClient *client;    //客户端
};

#endif // QTMQTT_H
